import unittest
from interface import chuankou
from utils.logger import Logger
logger = Logger(logger="TestCK").getlog()
class testCK(unittest.TestCase):
        #类执行前执行一次，不用多次打开关闭浏览器
    @classmethod
    def setUpClass(cls):
        """创建串口组件对象"""
        cls.d= chuankou.CLuster_SerialPortManage()
        cls.d.Init()
        logger.info("创建窗口组件对象")

    def test_01(self):
        """创建串口“COM1”"""
        logger.info("创建串口“COM1”")
        result= self.d.CreateSerialPort("COM1")
        self.assertEqual(result,True)

    def test_02(self):
        """创建串口“COM2”"""
        logger.info("创建串口“COM2”")
        result = self.d.CreateSerialPort("COM2")
        self.assertEqual(result,True)
    def test_03(self):
        """创建串口“COM3”"""
        logger.info("创建串口“COM3”")
        result = self.d.CreateSerialPort("COM3")
        self.assertEqual(result, True)
    def test_04(self):
        """创建串口“COM4”"""
        logger.info("创建串口“COM4”")
        result = self.d.CreateSerialPort("COM4")
        self.assertEqual(result, True)
    def test_05(self):
        """向串口COM2写入数据"""
        logger.info("向串口“COM2”写入数据'")
        result=self.d.WriteSerialPort("COM2","kk")
        self.assertEqual(result, True)
